Reduced instruction set for java virtual machines

ABSTRACT

Techniques for implementing virtual machine instructions suitable for execution in virtual machines are disclosed. The inventive virtual machine instructions can effectively represent the complete set of operations performed by the conventional Java Bytecode instruction set. Moreover, the operations performed by conventional instructions can be performed by relatively fewer inventive virtual machine instructions. Thus, a more elegant, yet robust, virtual machine instruction set can be implemented. This, in turn, allows implementation of relatively simpler interpreters as well as allowing alternative uses of the limited 256 (2 8 ) Bytecode representation (e.g., a macro representing a set of commands). As a result, the performance of virtual machines, especially, those operating in systems with limited resources, can be improved by using the inventive virtual machine instructions.

CROSS-REFERENCE TO RELATED APPLICATIONS

This is a continuation application of and claims priority under 35U.S.C. §120 to commonly owned and U.S. application Ser. No. 09/819,120,now U.S. Pat. No. 7,543,288, entitled “REDUCED INSTRUCTION SET FOR JAVAVIRTUAL MACHINES,” filed on Mar. 27, 2001, which is incorporated hereinby reference in its entirety and for all purposes.

This application is related to U.S. Pat. No. 6,957,428 entitled“ENHANCED VIRTUAL MACHINE INSTRUCTIONS,” which is hereby incorporatedherein by reference for all purposes.

This application is related to U.S. Pat. No. 6,901,591, entitled“IMPROVED FRAMEWORKS FOR INVOKING METHODS IN VIRTUAL MACHINES,” which ishereby incorporated herein by reference for all purposes.

This application is related to U.S. Pat. No. 6,978,456, entitled“IMPROVED METHODS AND APPARATUS FOR NUMERIC CONSTANT VALUE INLINING INVIRTUAL MACHINES,” which is hereby incorporated herein by reference forall purposes.

This application is related to U.S. Pat. No. 6,996,813, entitled“IMPROVED FRAMEWORKS FOR LOADING AND EXECUTION OF OBJECT-BASEDPROGRAMS,” which is hereby incorporated herein by reference for allpurposes.

BACKGROUND OF THE INVENTION

The present invention relates generally to object-based high levelprogramming environments, and more particularly, to virtual machineinstruction sets suitable for execution in virtual machines operating inportable, platform independent programming environments

Recently, the Java™ programming environment has become quite popular.The Java™ programming language is a language that is designed to beportable enough to be executed on a wide range of computers ranging fromsmall devices (e.g., pagers, cell phones and smart cards) up tosupercomputers. Computer programs written in the Java programminglanguage (and other languages) may be compiled into Java Bytecodeinstructions that are suitable for execution by a Java virtual machineimplementation.

The Java virtual machine is commonly implemented in software by means ofan interpreter for the Java virtual machine instruction set but, ingeneral, may be software, hardware, or both. A particular Java virtualmachine implementation and corresponding support libraries, togetherconstitute a Java™ runtime environment.

Computer programs in the Java programming language are arranged in oneor more classes or interfaces (referred to herein jointly as classes orclass files). Such programs are generally platform, i.e., hardware andoperating system, independent. As such, these computer programs may beexecuted without modification, on any computer that is able to run animplementation of the Java™ runtime environment. A class written in theJava programming language is compiled to a particular binary formatcalled the “class file format” that includes Java virtual machineinstructions for the methods of a single class. In addition to the Javavirtual machine instructions for the methods of a class, the class fileformat includes a significant amount of ancillary information that isassociated with the class. The class file format (as well as the generaloperation of the Java virtual machine) is described in some detail inThe Java Virtual Machine Specification by Tim Lindholm and Frank Yellin(ISBN 0-201-31006-6), which is hereby incorporated herein by reference.

Conventional virtual machines interpreter decodes and executes the JavaBytecode instructions, one instruction at a time during execution, e.g.,“at runtime.” To execute a Java instruction, typically, severaloperations have to been performed to obtain the information that isnecessary to execute the Java instruction. For example, to invoke amethod referenced by a Java bytecode, the virtual machine must performseveral operations to access the Constant Pool simply to identify theinformation necessary to locate and access the invoked method. Asdescribed in The Java Virtual Machine Specification, one of thestructures of a standard class file is known as the “Constant Pool.” TheConstant Pool is a data structure that has several uses. One of the usesof the Constant Pool that is relevant to the present invention is thatthe Constant Pool contains the information that is needed to resolvevarious Java Instructions. To illustrate, FIG. 1 depicts a conventionalcomputing environment 100 including a stream of Java Bytecodes 102, aconstant pool 104 and an execution stack 106. The stream of JavaBytecodes 102 represents a series of bytes in a stream where one or morebytes can represent a Java Bytecode instruction. For example, a byte 108can represent an Ldc (load constant on the execution stack) Bytecodecommand 108. Accordingly, the bytes 110 and 112 represent the parametersfor the Ldc Bytecode comand 108. In this case, these bytes respectivelyrepresent a CP-IndexA 100 and CP-IndexB 112 that collectively representthe index to appropriate constant value in the constant pool 104. Forexample, bytes C1, C2, C3 and C4 of the constant pool 104 cancollectively represent the appropriate 4 byte (one word) constant C thatis to loaded to the top of the execution stack 106. It should be notedthat Ldc Bytecode command 108 and its parameters represented by bytes110 and 112 are collectively referred to herein as a Java Bytecodeinstruction.

In order to execute the Java Bytecode Ldc Instruction 108, at run time,an index to the Constant Pool 104 is constructed from the CP-IndexA andCP-IndexA. Once an index to the Constant Pool has been determined, theappropriate structures in the Constant Pool have to be accessed so thatthe appropriate constant value can be determined. Accordingly, the JavaBytecode Ldc instruction can be executed only after performing severaloperations at run time. As can be appreciated from the example above,the execution of a relatively simple instruction such as loading aconstant value can take a significant amount of run time. Hence, thisconventional technique is an inefficient approach that may result insignificantly longer execution times.

Another problem is that the conventional Java Bytecode instruction sethas more than 220 instructions. Moreover, there is a significant amountof redundancy between some instructions in the conventional JavaBytecode instruction set. For example, there are different Java Bytecodeinstructions for storing (or pushing) integer local variables on theexecution stack (e.g., iLoad), and storing (or pushing) a pointer localvariable on the execution stack (e.g., aLoad). However, the operationsperformed by these instructions are virtually identical, namely, storing(or pushing) 4 byte values (a word) on the execution stack. There isalso a significant amount of overlap between some instructions of theconventional Java Bytecode instruction set. For example, there are 5different Java Bytecode instructions for pushing one byte integer valueson the execution stack (i.e., iconst_(—)1, iconst_(—)2, iconst_(—)3,iconst_(—)4 and iconst_(—)5). However, these operations virtuallyperform the same operations, namely, pushing a constant one byte integervalue on the execution stack.

As noted above, the Java Bytecode instruction set has more than 220instructions. This means that conventionally nearly all of the 256 (2⁸)allowable Bytecode values have to be assigned to Java instructions(commands or opcodes). As a result, Java interpreters are needlesslycomplex since they need to recognize a relatively large number of Javainstructions and possibly implement various mechanisms for executingmany instructions. Thus, the conventional Java Bytecode instruction setis not a very desirable solution for systems with limited resources(e.g., embedded systems)

Accordingly, there is a need for alternative instructions suitable forexecution in virtual machines.

SUMMARY OF THE INVENTION

To achieve the foregoing and other objects of the invention, techniquesfor implementing virtual machine instructions suitable for execution invirtual machines are disclosed. The inventive virtual machineinstructions can effectively represent the complete set of operationsperformed by the conventional Java Bytecode instruction set. Moreover,the operations performed by conventional instructions can be performedby relatively fewer inventive virtual machine instructions. Furthermore,the inventive virtual machine instructions can be used to performoperations that cannot readily be performed by conventional JavaBytecode instructions. Thus, a more elegant yet robust virtual machineinstruction set can be implemented. This in turn allows implementationof relatively simpler interpreters as well as allowing alternative usesof the limited 256 (2⁸) Bytecode representation (e.g., a macrorepresenting a set of commands). As a result, the performance of virtualmachines, especially, those operating in systems with limited resources,can be improved.

The invention can be implemented in numerous ways, including a system,an apparatus, a method or a computer readable medium. Severalembodiments of the invention are discussed below.

As a set of virtual machine instructions suitable for execution in avirtual machine, one embodiment of the invention provides a set ofvirtual machine instructions representing a number of corresponding JavaBytecode executable instructions that are also suitable for execution inthe virtual machine. The set of the virtual machine instructionsconsists of a number of virtual machine instructions which is less thanthe number of the corresponding Java Bytecode executable instructions.In addition, every one of the corresponding Java Bytecode executableinstructions can be represented by at least one of the virtual machineinstructions in the virtual machine instruction set.

As a method of converting a set of Java Bytecode executable instructionsinto a set of executable virtual machine instructions, one embodiment ofthe invention includes the acts of: receiving one or more bytesrepresenting a Java Bytecode instruction suitable for execution in avirtual machine; selecting a corresponding virtual machine instruction.The corresponding virtual machine instruction are suitable for executionin the virtual machine and represent one or more operations that can beperformed when the Java Bytecode instruction is executed. In addition,the virtual machine instruction can represent at least two or more JavaBytecode executable instructions such that operations that can beperformed by executing the at least two or more Java Bytecode executableinstructions can be performed by execution of the virtual machineinstruction.

As a Java Bytecode instruction translator, one embodiment of theinvention operates to convert a set of Java Bytecode executableinstructions suitable for execution on a virtual machine into a set ofcorresponding executable virtual machine instructions. The correspondingvirtual machine instructions are also suitable for execution in thevirtual machine and represent operations that can be performed byexecution of a number of corresponding Java Bytecode instructions. Inaddition, the corresponding set of the virtual machine instructionsconsists of a number of virtual machine instructions that is less thanthe number of the corresponding Java Bytecode executable instructions.

Other aspects and advantages of the invention will become apparent fromthe following detailed description, taken in conjunction with theaccompanying drawings, illustrating by way of example the principles ofthe invention.

BRIEF DESCRIPTION OF THE DRAWINGS

The present invention will be readily understood by the followingdetailed description in conjunction with the accompanying drawings,wherein like reference numerals designate like structural elements, andin which:

FIG. 1 depicts a conventional computing environment including a streamof Java Bytecodes, a constant pool, and an execution stack.

FIG. 2A is a block diagram representation of a computing environmentincluding a Java Bytecode instruction translator in accordance with oneembodiment of the invention.

FIG. 2B illustrates a mapping that can be performed by the Java Bytecodeinstruction translator of FIG. 2A in accordance with one embodiment ofthe invention.

FIG. 3 illustrates an internal representation of Java instructions inaccordance with one embodiment of the invention.

FIG. 4A illustrates an internal representation of a set of Java LoadConstant Bytecode instructions in accordance with one embodiment of theinvention.

FIG. 4B illustrates a set of conventional Java Bytecode instructionsthat can be represented by an inventive Push command.

FIG. 4C illustrates an internal representation of a set of conventionalJava Load Constant Bytecode instructions in accordance with anotherembodiment of the invention.

FIG. 4D illustrates a set of conventional Java Bytecode instructionsthat can be represented by a single PushL command in accordance with oneembodiment of the invention.

FIG. 4E illustrates an internal representation of a set of Java LoadConstant Bytecode instructions in accordance with yet another embodimentof the invention.

FIG. 4F illustrates a set of Java Bytecode instructions that can berepresented by a single PushB command in accordance with one embodimentof the invention.

FIG. 5A illustrates an internal representation of a set of Java Loadfrom a local variable instructions in accordance with another embodimentof the invention.

FIG. 5B illustrates a set of Java Bytecode instructions for loading 4byte local variables that can be represented by an inventive Loadcommand in accordance with one embodiment of the invention.

FIG. 5C illustrates a set of Java Bytecode instructions for loading 8byte local variables in accordance with one embodiment of the invention.

FIG. 6A illustrates a computing environment including an Aload (loadfrom array) virtual machine instruction in accordance with oneembodiment of the invention.

FIG. 6B illustrates a set of conventional Java Bytecode instructions forloading arrays that can be represented by a single inventive virtualmachine instruction in accordance with one embodiment of the invention.

FIG. 6C illustrates a computing environment including an AStore (storeinto array) virtual machine instruction in accordance with oneembodiment of the invention.

FIGS. 6D and 6E illustrate a set of conventional Java Bytecodeinstructions for storing arrays that can be represented by a singleinventive virtual machine instruction.

FIGS. 6F and 6G illustrate some Java conventional Bytecode instructionsfor performing conditional flow operations which can be represented bytwo inventive virtual machine instructions in accordance with oneembodiment of the invention.

FIG. 7A illustrates a computing environment including an internalrepresentation of a DUP instruction suitable for duplicating values onthe stack in accordance with one embodiment of the invention.

FIGS. 7B and 7C illustrate various Java Bytecode instructions that canbe represented by an inventive virtual machine instruction in accordancewith one embodiment of the invention.

FIGS. 8A and 8B illustrate mapping of Java Bytecode return instructionsto virtual machine instructions provided in accordance with oneembodiment of the invention.

FIG. 9 illustrates a mapping of Java Bytecode instantiation instructionsto the virtual machine instructions provided in accordance with oneembodiment of the invention

DETAILED DESCRIPTION OF THE INVENTION

As described in the background section, the Java programming environmenthas enjoyed widespread success. Therefore, there are continuing effortsto extend the breadth of Java compatible devices and to improve theperformance of such devices. One of the most significant factorsinfluencing the performance of Java based programs on a particularplatform is the performance of the underlying virtual machine.Accordingly, there have been extensive efforts by a number of entitiesto improve performance in Java compliant virtual machines.

To achieve this and other objects of the invention, techniques forimplementing virtual machine instructions suitable for execution invirtual machines are disclosed. The inventive virtual machineinstructions can effectively represent the complete set of operationsperformed by the conventional Java Bytecode instruction set. Moreover,the operations performed by conventional instructions can be performedby relatively fewer inventive virtual machine instructions. Furthermore,the inventive virtual machine instructions can be used to performoperations that cannot readily be performed by the conventional JavaBytecode instructions. Thus, a more elegant yet robust virtual machineinstruction set can be implemented. This, in turn, allows implementationof relatively simpler interpreters as well as allowing for alternativeuses of the limited 256 (2⁸) Bytecode representation (e.g., a macrorepresenting a set of commands). As a result, the performance of virtualmachines, especially, those operating in systems with limited resources,can be improved. Embodiments of the invention are discussed below withreference to FIGS. 2-9. However, those skilled in the art will readilyappreciate that the detailed description given herein with respect tothese figures is for explanatory purposes only as the invention extendsbeyond these limited embodiments.

FIG. 2A is a block diagram representation of a computing environment 200including a Java Bytecode instruction translator 202 in accordance withone embodiment of the invention. The Java Bytecode instructiontranslator 202 operates to convert one or more bytes of a Java Bytecodestream 204, representing a Java Bytecode instruction 205 into a virtualmachine instruction 206 containing one or more bytes. The Java Bytecodeinstruction 205 in the Java Bytecode stream 204 can be, for example, a“Lcd” command 108 with its associated parameters 110 and 112, asdescribed in FIG. 1.

Typically, one byte of the virtual machine instruction 206 is designatedto represent a virtual machine command (or opcode). In addition, one ormore additional bytes may be associated with the virtual machine command(or opcode) to represent its parameters. As a result, one or more bytesof the virtual machine instruction 206 can represent a Java Bytecodeinstruction having one or more bytes that collectively represent a JavaBytecode instruction, namely a command and possibly the parametersassociated with the command (e.g., a one byte Java iconst_(—)1 Bytecodeinstruction, three bytes representing Java Bytecode Lcd instruction,etc).

As will be appreciated, the virtual machine instruction 206 canrepresent similar virtual machine operations that the Java Bytecodeinstruction 205 represents. In addition, the virtual machine instruction206 can be loaded by a virtual machine instruction loader 208 into avirtual machine 210 as an internal representation 212. As will becomeapparent, the internal representation 212 can be used to significantlyimprove the performance of the virtual machine.

Furthermore, the Java Bytecode instruction translator 202 is capable ofconverting a set of Java Bytecode executable instructions into a moreelegant set of instructions that is especially suitable for systems withlimited resources. The operations performed by a conventional Bytecodeinstruction set can effectively be represented by fewer inventivevirtual machine instructions. Accordingly, the number of the executablevirtual machine instructions can be significantly less than the numberof conventional Java Bytecode executable instructions needed to performthe same set of operations. In other words, two or more distinctconventional Java Bytecode executable instructions can effectively bemapped into an inventive virtual machine instruction.

To elaborate, FIG. 2B illustrates a mapping 250 that can be performed,for example, by the Java Bytecode instruction translator 202 inaccordance with one embodiment of the invention. As illustrated in FIG.2B, a set of conventional Java Bytecode executable instructions 252 canbe mapped into a corresponding set of inventive virtual machineinstructions 254. It should be noted that the set of Java Bytecodeexecutable instructions 252 consists of M instructions, BytecodeInstructions (BC₁-BC_(M)). It should also be noted that each of the Bytecode Instructions BC₁-BC_(M) represent a unique instruction in the setof Java Bytecode executable instructions 252. As will be appreciated,the corresponding set of executable virtual machine instructions 254consists of N instructions (AVM₁-AVM_(N)), a number that can besignificantly less than M (the number of Java Bytecode executableinstructions 252). Accordingly, two or more Byte code Instructions ofthe Java Bytecode executable instructions 252 can be mapped into thesame executable virtual machine instruction. For example, BytecodeInstructions BC_(i), BC_(j) and BC_(k) can all be mapped into the samevirtual machine executable instruction, namely, the instruction AVM₁. Inaddition, as will be described below, two or more inventive virtualmachine instructions from the set 254 can be combined to effectivelyrepresent a Java Bytecode instruction in the set 252.

As noted above, a virtual machine instruction, for example, theinstruction AVM₁, can be loaded by a virtual machine instruction loaderinto a virtual machine as an internal representation that can be used tosignificantly improve the performance of the virtual machine. FIG. 3illustrates an internal representation 300 in accordance with oneembodiment of the invention. The internal representation 300 can, forexample, be implemented as a data structure embodied in a computerreadable medium that is suitable for use by a virtual machine. As shownin FIG. 3, the internal representation 300 includes a pair of streams,namely, a code stream 302 and a data stream 304.

It should be noted that conventionally Java Bytecode instructions areinternally represented as a single stream in the virtual machine.However, as shown in FIG. 3, the internal representation 300 includes apair of streams, namely, a code stream 302 and a data stream 304. Moredetails about representing instructions as a pair of streams can befound in the U.S. Pat. No. 6,996,813, entitled “IMPROVED FRAMEWORKS FORLOADING AND EXECUTION OF OBJECT-BASED PROGRAMS”.

Each one of the entries in the code stream 302 and/or data stream 304represents one or more bytes. The code stream 302 includes variousvirtual machine commands (or instructions) 306, 308 and 310. The virtualmachine commands (or instruction) 306 represent a virtual machineinstruction that does not have any parameters associated with it. On theother hand, each of the virtual machine commands B and C have associateddata parameters that are represented in the data stream 304. Moreparticularly, data B is the corresponding data parameter of the virtualmachine command B, and data C1 and C2 are the data parameters associatedwith the command C.

It should be noted that the inventive virtual machine command B and dataB represents one or more conventional Java Bytecodes which have beenconverted, for example, by the Java Bytecode instruction translator 202of FIG. 2A. Similarly, the virtual machine command C, data C1 and C2collectively represent the one or more Java Bytecodes that have beenconverted into an inventive virtual machine instruction with itsappropriate data parameters.

FIG. 4A illustrates an internal representation 400 of a set of Java LoadConstant Bytecode instructions in accordance with one embodiment of theinvention. The internal representation 400 can, for example, beimplemented as a data structure embodied in a computer readable mediumthat is suitable for use by a virtual machine.

In the described embodiment, each entry in the code stream 402 and datastream 404 represents one byte. As such, the code stream 402 includes aone byte Push command 406, representing an inventive virtual machinecommand suitable for representation of one or more conventional JavaLoad Constant Bytecode instructions. The data stream 404 includes thedata parameters associated with the Push command 406, namely, bytes A,B, C and D. As will be appreciated, at execution time, the virtualmachine can execute the Push command 406. Accordingly, the valuerepresented by the bytes A, B, C and D in the data stream 404 can bepushed on the execution stack. In this way, the Push command 406 caneffectively represent various Java Bytecode instructions that pushvalues represented by 4 bytes (one word) on the execution stack at runtime. FIG. 4B illustrates a set of conventional Java Bytecodeinstructions that can be represented by an inventive Push command (e.g.,Push command 406).

FIG. 4C illustrates an internal representation 410 of a set ofconventional Java Load Constant Bytecode instructions in accordance withanother embodiment of the invention. Similar to the internalrepresentation 400 of FIG. 4A, the internal representation 410 includesa pair of streams, namely, the code stream 402 and data stream 404,wherein each entry in the streams represents one byte. However, in FIG.4B, the code stream 402 includes a one byte PushL command 412,representing another inventive virtual machine instruction suitable forrepresentation of one or more Java Load Constant Bytecode instructions.It should be noted that the PushL command 412 has 8 bytes of dataassociated with it, namely, the bytes represented by A, B, C, D, E, F, Gand H in the data stream 404. At execution time, the virtual machine canexecute the PushL command 412 to push the value represented by the bytesA, B, C, D, E, F, G and H in the data stream 404, on the top of theexecution stack. Accordingly, the PushL command 412 can effectivelyrepresent various Java Bytecode instructions that push 8 byte (two word)values on the execution stack at run time. FIG. 4D illustrates a set ofconventional Java Bytecode instructions that can be represented by asingle PushL command (e.g., PushL command 412) in accordance with oneembodiment of the invention.

FIG. 4E illustrates an internal representation 420 of a set of Java LoadConstant Bytecode instructions in accordance with yet another embodimentof the invention. Again, the internal representation 420 includes thecode stream 402 and data stream 404, wherein each entry in the streamsrepresents one byte. However, in FIG. 4E, the code stream 402 includes aone byte PushB command 422, representing yet another inventive virtualmachine instruction suitable for representation of one or more Java LoadConstant Bytecode instructions. It should be noted that the PushBcommand 422 has a one byte data parameter A associated with it. As shownin FIG. 4E, the data parameter can be stored in the code stream 402.However, it should be noted that in accordance with other embodiment ofthe invention, the data parameter A can be stored in the data stream404. In any case, the PushB command 422 can effectively representvarious Java Bytecode instructions that push one byte values on theexecution stack at run time. FIG. 4F illustrates a set of Java Bytecodeinstructions that can be represented by a single PushB command (e.g.,PushB command 422) in accordance with one embodiment of the invention.

FIG. 5A illustrates an internal representation 500 of a set of Java“Load from a local variable” instructions in accordance with anotherembodiment of the invention. In the described embodiment, a code stream502 of the internal representation 500 includes a Load command 506,representing an inventive virtual machine instruction suitable forrepresentation of one or more Java “Load from a local variable” Bytecodeinstructions. It should be noted that the Load command 506 has a onebyte parameter associated with it, namely, an index_(i) 508 in the datastream 504. As will be appreciated, at run time, the Load command 506can be executed by a virtual machine to load (or push) a local variableon top of the execution stack 520. By way of example, an offset₀ 522 canindicate the starting offset for the local variables stored on theexecution stack 520. Accordingly, an offset_(i) 524 identifies theposition in the execution stack 520 which corresponds to the index_(i)508 shown in FIG. 5A.

It should be noted that in the described embodiment, the Load command506 is used to load local variables as 4 bytes (one word). As a result,the value indicated by the 4 bytes A, B, C and D (starting at offset_(i)524) is loaded on the top of the execution stack 520 when the Loadcommand 506 is executed. In this manner, the Load command 506 andindex_(i) 508 can be used to load (or Push) 4 byte local variables ontop of the execution stack at run time. As will be appreciated, the Loadcommand 506 can effectively represent various conventional Java Bytecodeinstructions. FIG. 5B illustrates a set of Java Bytecode instructionsfor loading 4 byte local variables that can be represented by aninventive Load command (e.g., Load command 412) in accordance with oneembodiment of the invention.

It should be noted that the invention also provides for loading localvariables that do not have values represented by 4 bytes. For example,FIG. 5C illustrates a set of Java Bytecode instructions for loading 8byte local variables in accordance with one embodiment of the invention.As will be appreciated, all of the Java Bytecode instructions listed inFIG. 5C can be represented by a single inventive virtual machineinstruction (e.g., a LoadL command). The LoadL command can operate, forexample, in a similar manner as discussed above.

In addition, the invention provides for loading values from arrays intoan execution stack. By way of example, FIG. 6A illustrates a computingenvironment 600 in accordance with one embodiment of the invention. Thecomputing environment 600 includes an array 602 representative of a Javaarray stored in a portion of a memory of the computing environment 600.An execution stack 604 is also depicted in FIG. 6. As will beappreciated, an inventive virtual machine instruction ALoad (array load)605 can be utilized to facilitate loading of various values from thearray 602 to the top of the execution stack 604.

During the execution of the virtual machine instruction ALoad 605, anarray-reference 606 can be utilized (e.g., resolved) to determine thelocation of the array 602. In addition, an array-index 608 can be usedto identify the appropriate offset of the array 602 and thereby indicatethe appropriate value that is to loaded from the array 602 on theexecution stack 604. As will be appreciated, the inventive virtualmachine instruction ALoad can be used to load the appropriate valuesfrom various types of arrays (e.g., 1 byte, 2 bytes, 4 bytes, 8 bytesarrays). To achieve this, a header 610 of the array 602 can be read todetermine the arrays' type. Accordingly, based on the type of the array602 as indicated by the header 610, the appropriate value that is to beloaded from the array can be determined by using the array-index 608.This value can then be loaded onto the top of the execution stack 604.

Thus, the inventive virtual machine instruction ALoad can effectivelyrepresent various Java Bytecode instructions that are used to loadvalues from an array. FIG. 6B illustrates a set of conventional JavaBytecode instructions for loading arrays that can be represented by asingle inventive virtual machine instruction (e.g., ALoad) in accordancewith one embodiment of the invention.

As will be appreciated, the invention also provides for virtual machineinstructions used to store values into arrays. By way of example, FIG.6C illustrates a computing environment 620 in accordance with oneembodiment of the invention. An inventive AStore 622 (store into array)virtual machine instruction can be used to store various values from theexecution stack 604 into different types of arrays in accordance with onembodiment of the invention. Again, the header 610 of the array 602 canbe read to determine the array's type. Based on the array's type, theappropriate value (i.e., the appropriate number of bytes N on theexecution stack 604 of FIG. 6B) can be determined. This value can thenbe stored in the array 602 by using the array-index 626. Thus, theinventive virtual machine instruction ALoad can effectively representvarious Java Bytecode instructions that are used to store values into anarray. FIGS. 6D and 6E illustrate a set of conventional Java Bytecodeinstructions for storing arrays that can be represented by an inventivevirtual machine instruction (e.g., Astore) in accordance with oneembodiment of the invention.

Still further, two or more of the inventive virtual machine instructionscan be combined to perform relatively more complicated operations inaccordance with one embodiment of the invention. By way of example, theconditional flow control operation performed by the Java Bytecodeinstruction “lcmp” (compare two long values on the stack and based onthe comparison push 0 or 1 on the stack) can effectively be performed byperforming an inventive virtual machine instruction LSUB (Longsubdivision) followed by another inventive virtual machine instructionJMPEQ (Jump if equal). FIGS. 6F and 6G illustrate some Java conventionalBytecode instructions for performing conditional flow operations whichcan be represented by two inventive virtual machine instructions inaccordance with one embodiment of the invention.

The invention also provides for inventive operations that cannot beperformed by Java Bytecode instructions. By way of example, an inventivevirtual machine operation “DUP” is provided in accordance with oneembodiment of the invention. The inventive virtual machine instructionDUP allows values in various positions on the execution stack to beduplicated on the top of the execution stack. FIG. 7A illustrates acomputing environment 700 including an internal representation 701 of aDUP instruction 702 suitable for duplicating values on the stack inaccordance with one embodiment of the invention. The internalrepresentation 701 includes a pair of streams, namely, a code stream 402and a data stream 404. In the described embodiment, each entry in thecode stream 402 and data stream 404 represents one byte. The inventivevirtual machine instruction DUP 702 is associated with a data parameterA in the code stream 402. Again, it should be noted that Data parameterA can be implemented in the data stream 404. In any case, the dataparameter A indicates which 4 byte value (word value) on an executionstack 704 should be duplicated on the top of the execution stack 704.The data parameter A can indicate, for example, an offset from the topof the execution stack 704. As shown in FIG. 7A, the data parameter Acan be a reference to W_(i), a word (4 byte) value on the executionstack. Accordingly, at execution time, the virtual machine can executethe DUP command 702. As a result, the W_(i) word will be duplicated onthe top of the stack. Thus, as will be appreciated, the inventive DUPvirtual machine instructions can effectively replace various Java Byteinstructions that operate to duplicate 4 byte values on top of theexecution. FIG. 7B illustrates some of these Java Bytecode instructions.Similarly, as illustrated in FIG. 7C, an inventive DUPL virtual machinecan be provided to effectively replace various Java Bytecodeinstructions that operate to duplicate 8 byte values (2 words) on top ofthe execution stack.

It should be noted that conventional Java Bytecode instructions onlyallow for duplication of values in certain positions on the executionstack (i.e, dup, dup_x1 and dupx2 respectively allow duplication of W1,W2 and W3 on the stack). However, the inventive virtual machineinstructions DUP and DUPL can be used to duplicate a much wider range ofvalues on the execution stack (e.g., W4, Wi, WN, etc.)

FIGS. 8A and 8B illustrate mapping of Java Bytecode “Return”instructions to virtual machine instructions provided in accordance withone embodiment of the invention. As shown in FIG. 8A, various JavaBytecode instructions can be effectively mapped into a Return virtualmachine instruction. As will be appreciated, the Return virtual machineinstruction operates to put 4 byte values (one word) on the executionstack in a similar manner as the virtual machine instructions forloading constants on the stack described above (e.g., iload). FIG. 8Billustrates a mapping of Java Bytecode return instructions to a“Lreturn” virtual machine instruction that can operate to put 8 bytevalues (two words) on the execution stack.

In a similar manner, FIG. 9 illustrates a mapping of Java Bytecodeinstantiation instructions to the virtual machine instructions providedin accordance with one embodiment of the invention. Again, the fourvarious Java Bytecode instructions can be effectively mapped into avirtual machine instruction (e.g., NEW). The virtual machine instructionNEW operates to instantiate objects and arrays of various types. In oneembodiment, the inventive virtual machine instruction NEW operates todetermine the types of the objects or arrays based on the parametervalue of the Bytecode instantiation instructions. As will beappreciated, the Bytecode instructions for instantiation are typicallyfollowed by a parameter value that indicates the type. Thus, theparameter value is readily available and can be used to allow the NEWvirtual machine instruction to instantiate the appropriate type atexecution time.

Appendix A illustrates mapping of a set of conventional Java Bytecodeinstructions to one or more of the inventive virtual machineinstructions listed the in right column.

The many features and advantages of the present invention are apparentfrom the written description, and thus, it is intended by the appendedclaims to cover all such features and advantages of the invention.Further, since numerous modifications and changes will readily occur tothose skilled in the art, it is not desired to limit the invention tothe exact construction and operation as illustrated and described.Hence, all suitable modifications and equivalents may be resorted to asfalling within the scope of the invention.

1. A non-transitory computer readable medium comprising: a computerprogram code for storing a reduced-set of virtual machine instructionssuitable for execution by a virtual machine, wherein the reduced-set ofvirtual machine instructions includes a first plurality of virtualmachine instructions that collectively represent a complete-set ofvirtual machine instructions which can be used to implement said virtualmachine, wherein said virtual machine may also be implemented by alarger-set of virtual machine instructions including a second pluralityof virtual machine instructions that collectively represent anothercomplete-set of virtual machine instructions which also can be used toimplement said virtual machine, wherein the number of virtual machineinstructions in said first plurality of virtual machines instructions ofsaid reduced-set is less than the number of instructions in said secondplurality of virtual machines instructions in said larger-set whereintwo or more bytecode executable instructions are represented by onevirtual machine instruction of the reduced-set of virtual machineinstructions.
 2. A computer readable medium as recited in claim 1,wherein said reduced-set includes at least one virtual machineinstruction which implements a functionality which is not provided byany of the virtual machine instructions in said larger-set.
 3. Acomputer readable medium as recited in claim 2, wherein said virtualmachine includes a code stream and a data stream, and wherein the codestream is designated for storing the code associated with virtualmachine instructions in said reduced-set of virtual machinesinstructions and the data stream is designated for storing the codeassociated with virtual machine instructions in said reduced-set ofvirtual machines instructions.
 4. A computer readable medium as recitedin claim 1, wherein said reduced-set includes: a push, a load, a store,a dup, a return, and a new instruction.
 5. A computer readable medium asrecited in claim 1 wherein at least one virtual machine instruction ofthe reduced-set of virtual machine instructions is mapped from aplurality of bytecodes associated with the larger set of virtual machineinstructions.
 6. A computer system, comprising: at least one hardwareprocessor executing a virtual machine, wherein said virtual machinereceives at least one instruction from a reduced-set of virtual machineinstructions, wherein said reduced-set of virtual machine instructionsincludes a first plurality of virtual machine instructions thatcollectively represent a complete set of virtual machine instructionsused to implement said virtual machine, wherein said virtual machine mayalso be implemented by a larger set of virtual machine instructionsincluding a second plurality of virtual machine instructions thatcollectively represent another complete set of virtual machineinstructions which also can be used to implement said virtual machine,wherein the number of virtual machine instructions in said firstplurality of virtual machines instructions of said reduced-set is lessthan the number of instructions in said second plurality of virtualmachines instructions in said larger-set and further wherein the atleast one instruction from the reduced-set of virtual machineinstructions implements at least two bytecode executable instructions.7. A computer system as recited in claim 6, wherein said reduced-setincludes: a push, a load, a store, a dup, a return, and a newinstruction.
 8. The computer system of claim 6 wherein the at least oneinstruction from the reduced-set of virtual machine instructions ismapped from at least two bytecodes associated with the larger set ofvirtual machine instructions.
 9. A non-transitory computer readablemedium comprising: a virtual machine being compatible with a definedvirtual machine specification that includes a defined set of executablevirtual machine instructions that must be implemented to conform withthe virtual machine specification, the virtual machine to execute areduced-set of virtual machine instructions that provide substantiallyall of the functionality provided by the defined virtual machineinstruction set, and wherein every one of the instructions in thedefined set of executable instructions can be represented by at leastone of the virtual machine instructions in the reduced virtual machineinstruction set, and wherein the reduced-set of virtual machineinstructions consists of a number of virtual machine instructions whichis less than the number executable virtual machine instructions in thedefined virtual machine instruction set and wherein at least one virtualmachine instruction of the reduced-set of virtual machine instructionsis mapped from a plurality of bytecodes associated with the defined setof virtual machine instructions.
 10. A virtual machine as recited inclaim 9, wherein said reduced-set includes: a push, a load, a store, adup, a return, and a new instruction.
 11. A virtual machine as recitedin claim 9, wherein said reduced-set of virtual machine instructionsincludes at least one virtual machine instruction that represents atleast one operation that cannot be represented by any one of the JavaBytecode executable instructions.
 12. A virtual machine as recited inclaim 9, wherein said reduced-set includes at least one virtual machineinstruction which implements a functionality which is not provided byany of the virtual machine instructions in said larger-set.
 13. A methodfor translating a first stream of Bytecodes that include virtual machineinstructions that are compliant with a defined-set of virtual machineinstructions that are defined by a virtual machine specification into areduced-set representation of Bytecodes that include only virtualmachine instructions that are part of a reduced-set of virtual machineinstructions, wherein the reduced-set of virtual machine instructionsprovide substantially all of the functionality provided by the definedvirtual machine instruction set and the number of virtual machineinstructions in the reduced-set of virtual machine instructions is lessthan the number of virtual instructions in the defined set of virtualmachine instructions, the method comprising: receiving, in at least onehardware processor, a first stream of Bytecodes that include a firstplurality of virtual machine instructions, wherein all of the virtualmachine instructions in the first stream of Bytecodes are included inand compliant with the defined virtual machine instructions set; andtranslating, in the at least one hardware processor, the first pluralityof virtual machine instructions into a second plurality of virtualmachine instructions, wherein all of the second plurality of virtualmachine instructions are included in and compliant with the reducedvirtual machine instruction set and wherein at least one of the secondplurality of virtual machine instructions implements the functionalityof at least two of virtual machine instructions of the defined virtualmachine instruction set.